package com.ipemon.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Logger {

	private static Logger self = null;
	private boolean stack = false;
	
	private List<String> logs = new ArrayList<String>();
	
	private Logger() {
		
	}
	
	public static Logger getInstance(){
		if(Logger.self==null) 
			Logger.self = new Logger();
		return Logger.self;
	}
	
	public void setStack(boolean mode) {
		stack = mode;
	}
	
	public void log(String log) {
		addLog("[Anonymous] [" + Thread.currentThread().getName() +"] " + log);
	}
	
	public void log(Object object, String log) {
		addLog("[" + object.getClass().getSimpleName() + "] [" + Thread.currentThread().getName() +"] " + log);
	}
	
	private void addLog(String log) {

			logs.add(log);
	}
	
	public List<String> getLogs() {
		return logs;
	}
	
	public void printLogs() {
		Iterator<String> iterator = logs.iterator();
		
		while(iterator.hasNext())
			System.out.println(iterator.next());
	}
	
}
